<?php

namespace Brandon
{
	class Response
	{
		/**
		 * @var string
		 */
		protected $_status;

		/**
		 * @var mixed
		 */
		protected $_data;

		/**
		 * Send response back to client
		 */
		public function send()
		{
			header('Content-Type: application/json');
			exit(json_encode(array(
				'status'	=> $this->_status,
				'data'		=> $this->_data,
			)));
		}

		/**
		 * Get/set status
		 * @param string $value
		 * @return mixed
		 */
		public function status($value = null)
		{
			if (null !== $value)
			{
				$this->_status = strtolower($value);
				return $this;
			}
			return $this->_status;
		}

		/**
		 * Get/set data
		 * @param array $value
		 * @return array
		 */
		public function data($value = null)
		{
			if (null !== $value && is_array($value))
			{
				$this->_data = (array) $value;
				return $this;
			}
			return (array) $this->_data;
		}
	}
}
